package cn.mrcode.fd.blog.common;

import cn.mrcode.fd.blog.entityCu.UserCu;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author : zhuqiang
 * @version : V1.0
 * @Description : 基础控制层
 * @date : 2015/12/16 22:03
 */
public class BaseController {
    public static final String  CHARSET_UTF8_JSON="application/json;charset=utf-8";

    @Autowired
    protected HttpServletRequest request;
    @Autowired
    protected HttpServletResponse response;
    @Autowired
    protected HttpSession session;

    protected UserCu getUser(){
        return (UserCu) session.getAttribute(BusConstant.SessionKey.USER_INFO);
    }

    protected String getDomain(){
        String domain = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
        return domain;
    }
}
